<template>
  <!-- 汇付余额明细 -->
  <el-dialog
    title="结算明细"
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    width="1200px"
    append-to-body
  >
  <el-form class="search-form-new" :model="queryParams" ref="queryForm" :inline="true">
      <div class="search-box">
       
        <el-form-item label="日期" prop="acctDate">
          <el-date-picker :clearable="false" v-model="queryParams.acctDate" type="date" placeholder="请选择日期"  value-format="yyyyMMdd"  >
          </el-date-picker>
        </el-form-item>
        <!-- <el-form-item label="类型" prop="status">
          <el-select clearable v-model="queryParams.status" placeholder="请选择类型"  >
            <el-option  label="充值" :value="1" />
            <el-option  label="扣除" :value="2" />
          </el-select>
        </el-form-item> -->

        <el-form-item class="btns">
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
          <!-- <el-button icon="el-icon-refresh" @click="resetQuery">重置/刷新</el-button> -->
        </el-form-item>
      </div>
    </el-form>
  <div class="table_box">
    <el-table
        :data="tableData.records"
        style="width: 100%"
        stripe
        border
      >
      <!-- <el-table-column
          prop="tenantName"
          label="商户"
          show-overflow-tooltip
        ></el-table-column>
      <el-table-column
          prop="createName"
          label="用户"
          show-overflow-tooltip
        ></el-table-column> -->
        <el-table-column
          prop="trans_date_time"
          label="时间"
          width="160"
        >
      
        <template slot-scope="scope">
          <span>{{ formatTime(scope.row.trans_date_time) }}</span>
        </template>  
      </el-table-column>
        <el-table-column prop="acct_trans_type" label="类型" ></el-table-column>
        <el-table-column prop="trans_amt" label="变动金额" ></el-table-column>
        <el-table-column prop="fee_amt" label="手续费金额" ></el-table-column>
        <el-table-column prop="balance_amt" label="变动后余额" ></el-table-column>
    
        
      </el-table>

    <pagination :layout="'prev, next'" :total="tableData.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  </div>
  </el-dialog>
  
</template>
<script>
import { mapGetters } from "vuex";
import { hfBalanceQueryMx } from "@/api/tenantApis/tenantManage";
export default {
  name: "",
  computed: {
    ...mapGetters(["userInfo"]),
  },
  data() {
    return {
      dialogVisible:false,
      timer:[],
      tableData:{
        records:[],
        total:0,
      },
      
      // 查询参数
      queryParams: {
        pageNum:1,
        pageSize: 10,
        acctDate:''

      },
      defaultDate:''
    };
  },
  created() {
  },
  computed:{
    formatTime(){
      return (time)=>{
        const year = time.slice(0, 4)
        const month = time.slice(4, 6)
        const day = time.slice(6, 8)
        const hh = time.slice(8, 10)
        const mm = time.slice(10, 12)
        const ss = time.slice(12, 14)
        return `${year}-${month}-${day} ${hh}:${mm}:${ss}`
      }
    },
  },
  methods: {
    open(){
      const now = new Date()
      const year = now.getFullYear()
      const month = now.getMonth()+1
      const day = now.getDate()

      this.queryParams.acctDate = `${year}${month>9?month:'0'+month}${day>9?day:'0'+day}`
      this.dialogVisible = true
      this.getList()
    },
    // 获取列表
    getList() {
      // queryParams 请求列表
      this.loading = true;
 
      hfBalanceQueryMx(this.queryParams).then((res) => {
        this.loading = false;
        this.tableData.records = []
        if(res.code==200&&res.data&&res.data.code==200&&res.data.data){
          if(res.data.data.resp_code=='00000000'&&res.data.data.acct_log_list){
            this.tableData.records = JSON.parse(res.data.data.acct_log_list)
            // console.log("%c Line:120 🍺 this.tableData.records", "color:#ffdd4d", this.tableData.records);
            this.tableData.total = Number(res.data.data.result_count)
          }else{

          }
          
        }
        
      });
    },

   
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.timer = []
      this.handleQuery();
    },
    resetQuery() {
      this.timer = [];
      this.queryParams = {
        pageNum: 1,
        pageSize: 20,
        createTimeStart: "",
        createTimeEnd: ""
      };
      this.getList();
    },

  }
};
</script>
<style lang="scss" scoped>
  .app-container{
    .search-box{
      // width: 790px;
      // margin: 0 auto;
    }
  }
  ::v-deep .el-date-editor{
    .el-input__inner{
      padding-left: 30px;
    }
  }
</style>
